import {Form, Switch} from "antd";
import BaseEntity from "@/type/BaseEntity";
import InputProps from "@/common/form/porps";
import type {Rule} from "rc-field-form/lib/interface";

interface IProps<T extends BaseEntity> extends InputProps<T>{
    loading?: boolean,
}
const InputSwitch = <T extends BaseEntity>(props: IProps<T>) => {
    const rules: Rule[] = [
        {
            required: props.required,
            message: `请选择${props.label}值!`
        },
    ];
    return (
        <Form.Item<T> name={props.name as any} label={props.label} required={props.required} rules={rules}>
            <Switch loading={props.loading} disabled={props.disabled} />
        </Form.Item>
    );
};

export default InputSwitch;